var sampmons = new Vue({
	el:'#sampmons',
	data:{
		token:"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyaWQiOiJsaXV5YW5nIiwidXNlclB3ZCI6IjEyMzQ1NiIsInVzZXJOYW1lIjoiQWRtaW4iLCJVSWQiOiI2ZTJjNDQ5YS05Y2UxLTQxMmItYmFjOC1mZjdjMzY5ODE0ZTAifQ.-_GYkZe9zumBZxUfpRXV6-ojYgw6Zw1L4uwWLD1myJk",
		mons_all:[],
		mons_all_search:[],
		samplingcode:"",
		mons_sele:[],
		key_left:"",
		key_right:"",
		isloading:true,
		IsSence:false,
		
	},
	mounted:function(){
	},
	computed:{
		mons_sele_search(){
			return function(key_right){
				var _mons_sele_search=[]
				if(key_right){
					this.mons_sele.forEach(function(item,index){
						if(item.Name.includes(key_right)){
							_mons_sele_search.push(item)
						}
					})
				}else{
					_mons_sele_search = this.mons_sele
				}
				return _mons_sele_search
			}
		}
	},
	watch:{
		mons_all:function(){
			this.$nextTick(function(){
				this.isloading = false
				this.initSele()
			})
		}
	}
	,
	methods:{
		GetMonsByTagId(tagId){
			return axios.get(example.requestpath+'/api/Project/GetMonsByTagId',{
						params:{
							tagId:tagId
						},
						headers:{token:this.token}
					})
		}
		,
		initSele(){
			var _this = this
			var obj = vueData.currentmonSele
			_this.mons_sele = []
			obj.data.forEach(function(item,index){
				for(var i = 0;i<_this.mons_all.length;i++){
					if(item.MonitemName == _this.mons_all[i].Name){
						_this.mons_sele.push(_this.mons_all[i])
						continue
					}
				}
			})
			// this.samplingcode = obj.data[0].MonitemId
			this.IsSence = obj.sence
		}
		,
		allsearch(value){
			var _this = this
			this.mons_all_search = []
			this.mons_all.forEach(function(item,index){
				if(item.Name.includes(value))
				{
					_this.mons_all_search.push(item)
				}
			})
		}
		,
		selesearch(val){
			
		},
		backBtn(){
			var samplingcode = this.samplingcode
			var slist=[]
			var _this = this
			this.mons_sele.forEach(function(item){
				slist.push({
					IsSence:_this.IsSence,
					MonitemId:item.Id,
					MonitemName:item.Name,
					SampingCode:samplingcode
				})
			})
			
			var olist = []
			vueData.samplingObj.Mons.forEach(function(item){
				if(item.IsSence != _this.IsSence){
					olist.push(item)
				}
			})
			olist.forEach(function(item,index){
				slist.forEach(function(item1){
					if(item.MonitemId == item1.MonitemId){
						olist.splice(index,1)
					}
				})
			})
			
			slist = slist.concat(olist)
			vueData.samplingObj.Mons = slist
			vueData.sampDetail[vueData.samplingObjindex] = vueData.samplingObj
			
			
			
			
			service.sampdetailExt()
		},
	}
})